# Copyright (c) 2008 Peter Philips
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
class RicalMigrationGenerator < Rails::Generator::Base

   def manifest
      record do |m|

         # Always create the model with the search functions
         # m.directory File.join('app/models', class_path)
         # m.template 'model.rb', 
         #        File.join('app/models', 
         #                   class_path, 
         #                  "#{file_name}.rb")

         # Unless they pass --skip-migration, also create a new example
         # migration for the user to hack on.
         #unless options[:skip_migration]
            m.migration_template 'migration.rb', 
                                 'db/migrate', 
                                  # :assigns => { :rical_prefix => class_name.downcase }, 
                                  #TODO: if i use dynamic prefixing then i need to generate the models
                                  #      if I don't do dynamic prefixing, there might be namespace overlap
                                  :assigns => { :rical_prefix => "rical" }, 
                                  :migration_file_name => "create_rical_models"
         #end

      end
   end 
  protected
    # Override with your own usage banner.
    def banner
      "Usage: #{$0} rical [--skip-migration] [table_prefix](not currently used) "
    end

    # Override to add your options to the parser:                                                                          
    #   def add_options!(opt)
    #     opt.on('-v', '--verbose') { |value| options[:verbose] = value }                                                  
    #   end
    def add_options!(opt)                                                                                                  
      #opt.on('-m', '--skip-migration') { |value| options[:skip_migration] = true }                                                  
    end       


end

